<!--
 *@Date: 2022-12-21 10:05:09
 * @LastEditTime: 2022-12-28 16:43:01
 *
 * @Description:
-->

<template>
    <uni-datetime-picker type="datetime" v-model="datetime" @change="dateChange" />
</template>
<script setup lang="ts">
import { onMounted, ref, watch } from 'vue';
import dayjs from 'dayjs';
const datetime = ref("")
const props = defineProps({
    modelValue: {
        type: String,
    }
})

watch(() => props.modelValue, (newValue) => {
    if (newValue) {
        datetime.value = dayjs(newValue, "YYYYMMDDHHmmss").format("YYYY-MM-DD HH:mm:ss")
    }
})


if (props.modelValue) {
    datetime.value = dayjs(props.modelValue, "YYYYMMDDHHmmss").format("YYYY-MM-DD HH:mm:ss")
}



const emits = defineEmits(['update:modelValue']);
const dateChange = (e: any) => {
    emits('update:modelValue', dayjs(e, "YYYY-MM-DD HH:mm:ss").format("YYYYMMDDHHmmss"))
}

</script>
<style lang="scss" scoped>

</style>
